package com.learn.springframework.bean.support;

import com.learn.springframework.bean.config.BeanDefinition;
import com.learn.springframework.core.BeanFactory;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author MI
 */
public class DefaultListableBeanFactory implements BeanFactory {

    public Map<String, BeanDefinition> beanDefinitionMap = new HashMap<String, BeanDefinition>();

    @Override
    public Object getBean(String name) {
        return null;
    }

    @Override
    public Object getBean(Class beanClass) {
        return null;
    }

    public void doRegistryBeanDefinition(List<BeanDefinition> beanDefinitions) throws Exception {
        for (BeanDefinition beanDefinition : beanDefinitions) {
            if (this.beanDefinitionMap.containsKey(beanDefinition.getFactoryBeanName())) {
                throw new Exception("The "+beanDefinition.getFactoryBeanName()+" is exists !!!");
            }
            this.beanDefinitionMap.put(beanDefinition.getFactoryBeanName(), beanDefinition);
        }
    }
}
